package com.zisuyi.gamesdkdemo

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.weilele.mvvm.gson
import com.weilele.mvvm.utils.activity.toast
import com.weilele.mvvm.widget.BaseRecyclerView
import com.zisuyi.game.sdk.game.GameActivity
import com.zisuyi.game.sdk.library.login.IGameLogin
import com.zisuyi.game.sdk.module.HttpActivity

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        testHttp()
        testFbLogin()
        testGoogleLogin()
        toGame()
    }

    private fun toGame() {
        findViewById<View>(R.id.toGame).setOnClickListener {
            GameActivity.start(this)
        }
    }

    private fun testHttp() {
        findViewById<View>(R.id.toGame).setOnClickListener {
            HttpActivity.start(this)
        }
    }

    private fun testFbLogin() {
        val login = IGameLogin.invoke(supportFragmentManager, this, IGameLogin.LOGIN_FACEBOOK)
        login.addOnLoginListener(object : IGameLogin.OnLoginListener {
            override fun onSuccess(info: IGameLogin.UserInfo, type: String) {
                "登录成功".toast()
            }

            override fun onCancel(type: String) {
                "登录取消".toast()
            }

            override fun onError(error: Throwable, type: String) {
                "登录失败".toast()
            }
        })
        findViewById<View>(R.id.facebookLogin).setOnClickListener {
            login.requestLogin()
        }
    }

    private fun testGoogleLogin() {
        val login = IGameLogin.invoke(supportFragmentManager, this, IGameLogin.LOGIN_GOOGLE)
        login.addOnLoginListener(object : IGameLogin.OnLoginListener {
            override fun onSuccess(info: IGameLogin.UserInfo, type: String) {
                "登录成功".toast()
            }

            override fun onCancel(type: String) {
                "登录取消".toast()
            }

            override fun onError(error: Throwable, type: String) {
                "登录失败".toast()
            }
        })
        findViewById<View>(R.id.googleLogin).setOnClickListener {
            login.requestLogin()
        }
    }

    //    private class Adapter :RecyclerView.Adapter<Holder>(){
//        private val list= listOf(
//            "facebook login",{}
//        )
//        override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
//
//        }
//
//        override fun onBindViewHolder(holder: Holder, position: Int) {
//
//        }
//
//        override fun getItemCount(): Int {
//
//        }
//        private fun faceBookLogin
//
//    }
    private class Holder(itemView: View) : RecyclerView.ViewHolder(itemView)

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
    }
}